<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>simMoveToObject</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../../index.html" TARGET="_top"><img src="../images/homeImg.png"></a></p>

<h1><a href="../apiOverview.htm">Regular API</a> function</h1>
<h3 class=subsectionBar><a name="simMoveToObject" id="simMoveToObject"></a>simMoveToObject / sim.moveToObject </h3>
<table class=apiTable>
<tr class=apiTableTr> 
<td class=apiTableLeftDescr>
Description 
</td> 
<td class=apiTableRightDescr>Moves an object to the position/orientation of another moving object (target object) by performing interpolations (i.e. the object will effectiviely follow the target object). If the target object is a path, a position on the path can be specified. If the target object is not moving, use rather <a href="simGetObjectPosition.htm">sim.getObjectPosition</a>, <a href="simGetObjectOrientation.htm">sim.getObjectOrientation</a> or <a href="simGetPositionOnPath.htm">sim.getPositionOnPath</a>, <a href="simGetOrientationOnPath.htm">sim.getOrientationOnPath</a> in conjunction with <a href="simRMLMoveToPosition.htm">sim.rmlMoveToPosition</a>. This function can only be called from <a href="../childScripts.htm">child scripts</a> running in a thread (since this is a blocking operation) and is not available from the C-API. See also <a href="simFollowPath.htm">sim.followPath</a>.<br></td>
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCSyn>
C synopsis
</td> 
<td class=apiTableRightCSyn><div></div></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCParam>C parameters</td> 
<td class=apiTableRightCParam>
<div></div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCRet>
C return value
</td> 
<td class=apiTableRightCRet>
<div></div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLSyn>
Lua synopsis
</td> 
<td class=apiTableRightLSyn>number deltaTimeLeft=sim.moveToObject(number objectHandle,number targetObjectHandle,number positionAndOrOrientation,number relativeDistanceOnPath,number velocity,number acceleration)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLParam>Lua parameters</td> 
<td class=apiTableRightLParam>
<div><strong>objectHandle</strong>: handle of the object to be moved</div>
<div><strong>targetObjectHandle</strong>: handle of the object to be followed</div>
<div><strong>positionAndOrOrientation</strong>: a value between 1 and 3 (1: only position is modified, 2: only orientation is modified, 3: position and orientation is modified). Can be nil in which case 3 is applied.<br>
</div>
<div><strong>relativeDistanceOnPath</strong>: a value between 0 and 1, where 0 is the beginning of the path, and 1 the end of the path. Make sure you selected the appropriate <a href="../pathPositionCalculationMethod.htm">path length calculation method</a>. Can be nil in which case the path object is treated as a regular object.<br>
</div>
<div><strong>velocity</strong>: movement velocity expressed in 1/s (i.e. the inverse of the velocity indicates the time that will be taken to reach the target object)<br>
</div>
<div><strong>acceleration</strong>: the acceleration/deceleration expressed in 1/s^2. Can be nil in which case an infinite acceleration is applied.</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLRet>
Lua return values
</td> 
<td class=apiTableRightLRet>
<div><strong>deltaTimeLeft</strong>: if the time needed to reach the target object is not a multiple of the simulation time step, then deltatimeLeft is the execution time left at current simulation time. deltaTimeLeft is also memorized internally on a thread-basis and used as compensation or correction factor in subsequent blocking commands.</div>
</td> 
</tr> 
</table> 

<br>
<p><a href="../apiFunctions.htm">All regular API functions on one page</a></p>
<br>
<br>
</td>
</tr>
</table>
</div>
</body>
</html>
